package com.chinasoft.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class AOPAdvice {

    public void before(JoinPoint jp){
        Object[] args = jp.getArgs();
        System.out.println("before..."+ args[0] );
    }

    public void after(JoinPoint jp){
        Object[] args = jp.getArgs();
        System.out.println("after..."+ args[0] );
    }
    public void afterReturnning(Object ret){

        System.out.println("afterReturnning..."+ ret );
    }
    public void afterThrowing(Throwable t){

        System.out.println("afterThrowing..."+ t.getMessage() );
    }

    public Object around(ProceedingJoinPoint pjp){
        System.out.println("around before ... ");
        Object ret = null;
        try{
            ret = pjp.proceed();//原始方法调用
        }catch (Throwable throwable){
            System.out.println("around  throwable" + throwable.getMessage());
        }
        System.out.println("around after ... " + ret);
        return ret;
    }
}